package base

import (
	"context"
	"mall/common/globalkey"
	"mall/service/backend/api/internal/svc"
	"mall/service/backend/api/internal/types"

	"github.com/zeromicro/go-zero/core/logx"
)

type InitJobDatabaseLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewInitJobDatabaseLogic(ctx context.Context, svcCtx *svc.ServiceContext) *InitJobDatabaseLogic {
	return &InitJobDatabaseLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *InitJobDatabaseLogic) InitJobDatabase(req *types.IDsReq) (resp *types.BaseMsgResp, err error) {
	err = l.CreateFeedbackLogic(globalkey.GorseKnowledgeBasePrefix+"2", "10000", "1")
	if err != nil {
		return nil, err
	}
	return
}

func (l *InitJobDatabaseLogic) CreateFeedbackLogic(pid, uid string, fType string) error {
	return l.svcCtx.GorseClient.CreateFeedback(
		l.svcCtx.Config.Query.GorseUrl,
		pid, uid,
		fType,
	)
}
